﻿using OblivionLevelingHelper.Attributes;
namespace OblivionLevelingHelper.Skills
{
    public class Skill
    {
        protected const int BaseLevel = 5;
        public int Level = 0;
        public SkillTypes SkillType { get; private set; }
        public Attribute GovernedAttribute { get; set; }
        private readonly Character _parent;
        
        public Skill(SkillTypes skillType, Character parent)
        {
            SkillType = skillType;
            _parent = parent;
        }

        public int CalculateStat()
        {
            var stat = BaseLevel + Level;
            stat += IsMajor() ? 20 : 0;
            stat += _parent.Class.Specialization.GetSkillModifier(SkillType);
            stat += _parent.Race.GetSkillModifier(SkillType);
            return stat;
        }

        public string GetName()
        {
            return SkillType.ToString();
        }

        public bool IsMajor()
        {
            return _parent.Class.HasMajorSkill(SkillType);
        }

        public void SetGovernedAttribute(Attribute attribute)
        {
            GovernedAttribute = attribute;
            attribute.AddGoverningSkill(this);
        }
    }
}
